package com.ledim.adapter;

import android.app.Activity;
import android.support.v4.view.ViewPager;
import com.ledim.bean.LedimCardGroupBean;
import com.ledim.utils.LedimViewHolder;
import com.ledim.widget.viewPager.BeeViewPager;
import com.ledim.widget.viewPager.NoScrollViewPager;
import com.ledim.widget.viewpagerindicator.BeeCirclePageIndicator;
import com.letv.android.young.client.R;

/**
 * Created by ccx on 16/7/27.
 * 精选组卡片8adapter
 */
public class CardGroup8Adapter extends CarGroupBaseAdapter {

    private NoScrollViewPager mViewPager;
    private BeeCirclePageIndicator mBannerIndicator;
    private CardA8PageAdapter mCardA8Adapter;

    public CardGroup8Adapter(Activity activity, LedimCardGroupBean cardGroup) {
        super(activity, cardGroup);
    }

    @Override
    public void initView(LedimViewHolder viewHolder) {

        mViewPager = viewHolder.getView(R.id.card_a8_list_pager);
        mBannerIndicator = viewHolder.getView(R.id.card_a8_list_indicator);
        if (mCardGroupBean != null && mCardGroupBean.cards != null &&
                mCardGroupBean.cards.size() > 0) {

            mCardA8Adapter =
                    new CardA8PageAdapter(mActivity, mCardGroupBean.cards, mCardGroupBean.id);
            mViewPager.setAdapter(mCardA8Adapter);
            mBannerIndicator.setViewPager(mViewPager, 0);
            mBannerIndicator.requestLayout();

            mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

                @Override
                public void onPageSelected(int arg0) {
                    mBannerIndicator.setCurrentItem(arg0);
                }

                @Override
                public void onPageScrolled(int arg0, float arg1, int arg2) {
                }

                @Override
                public void onPageScrollStateChanged(int arg0) {

                }
            });
        }
    }

}
